﻿using System.Security.Cryptography;
using System.Text;

namespace StudyCompanion.Commons.Encrypt;

public class DesEncryption
{
    /// <summary>
    ///     des加密
    /// </summary>
    /// <param name="original"></param>
    /// <param name="key"></param>
    /// <returns></returns>
    public static string Encrypt(string original, string key)
    {
        var buff = Encoding.Default.GetBytes(original);
        var kb = Encoding.Default.GetBytes(key);
        using var des = TripleDES.Create();
        des.Key = kb;
        return Encoding.Default.GetString(des.CreateEncryptor().TransformFinalBlock(buff, 0, buff.Length));
    }
}